/*
 * @Author: ZhanXie
 * @Date: 2020-09-06 11:50:41
 * @LastEditors: ZhanXie
 * @LastEditTime: 2020-09-06 12:16:20
 * @Description: 个人主页 controller
 * @FilePath: /weibo/src/controller/blog-profile.js
 */

const { getBlogListByUser } = require('../services/blog')
const { PAGE_SIZE } = require('../conf/const')
const { SuccessModel } = require('../model/ResModel')

async function getProfileBlogList(userName, pageIndex = 0) {
  const result = await getBlogListByUser({
    userName,
    pageIndex,
    pageSize: PAGE_SIZE
  })
  const blogList = result.blogList

  // 拼接返回数据
  return new SuccessModel({
    isEmpty: blogList.length === 0,
    blogList,
    pageSize: PAGE_SIZE,
    pageIndex,
    count: result.count
  })
}

module.exports = {
  getProfileBlogList
}